package data.content;

import java.util.Random;

import junit.framework.Assert;

import org.junit.Test;

public class ContentSentenceTest {

  @Test
  public void testContentSentence() {
    int lengths[] = {0,1,2,5,15,ContentSentence.CONTENT_SENTENCE_MAX_LENGTH};
    String diff_string = "abc";
    Random rnd = new Random();
    for (int i = 0; i < lengths.length; ++i) {
      char[] chars = new char[lengths[i]];
      for (int j = 0; j < lengths[i]; ++j) {
        chars[j] = (char)rnd.nextInt(128);
      }
      ContentSentence cs = new ContentSentence(String.valueOf(chars));
      Assert.assertEquals("ContentSentence: getSentence fails",
          cs.getSentence(), String.valueOf(chars));
      Assert.assertEquals("ContentSentence: toString fails",
          cs.toString(), String.valueOf(chars));
      Assert.assertTrue("ContentSentence: equals fails",
          cs.equals(new ContentSentence(String.valueOf(chars))));
      Assert.assertTrue("ContentSentence: equals fails",
          cs.equals(cs));
      Assert.assertFalse("ContentSentence: equals fails",
          cs.equals(null));
      Assert.assertFalse("ContentSentence: equals fails",
          cs.equals((Integer)5));
      Assert.assertFalse("ContentSentence: equals fails",
          cs.equals(new ContentSentence(diff_string)));
    }
  }

  @Test(expected=AssertionError.class)
  public void testGetSentenceAssertion1() {
    int len = ContentSentence.CONTENT_SENTENCE_MAX_LENGTH + 1;
    char[] chars = new char[len];
    for (int j = 0; j < len; ++j) {
      chars[j] = 'a';
    }
   ContentSentence cs = new ContentSentence(String.valueOf(chars));
   System.out.println(cs);
  }

}
